<?php

namespace application\common\controller;

use ticky\controller;

class common extends controller {

    public function __construct() {

    }

    /**
     * 获取内容页URL
     * @param $catid
     * @param $id
     */
    public function get_url($catid, $id) {
        $url_rule = get_config('url_rule');
        $ext = config('http', 'default_extension');
        //如果系统设置是伪静态模式
        if ($url_rule) {
            $catinfo = get_category($catid);
            $url = URL_MODEL == 1 ? 'index.php?s=/' . $catinfo['catdir'] . '/' . $id . $ext : '/' . $catinfo['catdir'] . '/' . $id . $ext;
        } else {
            $url = url('home/index/show', array('catid' => $catid, 'id' => $id));
        }
        return $url;
    }

    /**
     * 设置当前语言
     */
    public function lang() {
        switch ($_GET['lang']) {
            case 'cn':
                cookie('ticky_var', 'zh-cn');
                break;
            case 'en':
                cookie('ticky_var', 'en-us');
                break;
            default :
                cookie('ticky_var', 'zh-cn');
                break;
        }
        echo json_encode(array('status' => 1));
    }

}
